/**
 * 登录后，延迟检测是否有计划跟踪需要提醒
 */

//页面载入初始化
$( "body" ).ready( function( e )
{
	setTimeout( "load_tracking()", 1000 );
} );

function load_tracking()
{
	$.post( "consultant_tracking_remind_search.php", null, function( value )
	{
		var d = $.parseJSON( value );
		var msger = get_msger();

		if( d.err == 0 )
		{
			if( d.size <= 0 )
				return;

			
			for( var i = 0; i < d.size; i++ )
			{
				v = d[ i ];
				v.province = empty( v.province ) ? "未知" : v.province;
				v.city = empty( v.city ) ? "未知" : v.city;
				msger.msg( "<b>[计划跟踪]</b> <a>" + v.nickname + "，" + v.sourcens + "，" + v.categoryns + " ["
						+ v.province + "-" + v.city + "]</a>", function( e )
				{
					var checkbox = e.data.self.find( "input:checkbox" );
					tracking( e.data.client );
					checkbox.prop( "checked" ) && tracking_sign( e.data.key );
				}, v );
			}
			msger.open( "今日计划跟踪提醒" );
		}
		else
		{
			infopad.err( d.msg, d.delay );
		}
	} );
}

function tracking_sign( key )
{
	$.post( "consultant_tracking_remind_sign.php", { key: key }, function( value )
	{
	} );
}

function tracking( key )
{
	if( !empty( key ) )
		$( '#content_container' ).attr( 'src', 'consultant_client_tracking.php?key=' + key );
}
